<template>
	<view class="container">
		<view class="app" v-for="(item,index) in foods" :key="item._id">
			<uni-section :title="item.fname" type="line">
				<uni-card :cover="cover">
					<text class="uni-body">
						菜品描述:{{item.detail}}
						原价:{{item.normprice}}
						特价:{{item.realprice}}
						<button>加入购物车</button>
					</text>
				</uni-card>
			</uni-section>
		</view>
		<uni-fab ref="fab" :pattern="pattern" horizontal="right" vertical="bottom" @fabClick="fabClick()" />
		<uni-popup ref="popup" background-color="#fff">
			<view class="popup-content" :class="{ 'popup-height': type = 'left' }">
				<text class="text">
					时间紧迫 就不做了
				</text>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				foods: [],
				pattern: {
					color: '#7A7E83',
					backgroundColor: '#fff',
					selectedColor: '#007AFF',
					buttonColor: '#007AFF',
					iconColor: '#fff'
				},
				type: "left"
			}
		},
		onLoad() {
			this.showAllFoods()
		},
		methods: {
			showAllFoods() {
				uniCloud.callFunction({
					name: "xmsCloudFun"
				}).then(res => {
					this.foods = res.result.data
					console.log(res)
					console.log(this.foods)
				})
			},
			fabClick() {
				this.$refs.popup.open(this.type)
			}
		}
	}
</script>

<style lang="scss">
	.popup-height {
		width: 200px;
	}
</style>
